﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Nvigorate.Aspect;

namespace Nvigorate.Test.Aspect
{
    /// <summary>
    /// Summary description for ArgumentCheckAspectTests
    /// </summary>
    [TestClass]
    public class ArgumentCheckAspectTests
    {
        public ArgumentCheckAspectTests()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestNoArguments()
        {
            var test = new TestNullArgs();
            test.Test();
        }


        [TestMethod]
        public void Test1Argument_Pass()
        {
            var test = new TestNullArgs();
            test.Test1Arg("pass");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException), 
            "Parameter name: Parameter(s) arg1 cannot be null for method Nvigorate.Test.Aspect.TestNullArgs.Test1Arg.")]
        public void Test1Argument_Fail()
        {
            var test = new TestNullArgs();
            test.Test1Arg(null);
        }

        [TestMethod]
        public void Test2Argument_Pass()
        {
            var test = new TestNullArgs();
            test.Test2Args("pass", "pass");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException),
            "Parameter name: Parameter(s) arg2 cannot be null for method Nvigorate.Test.Aspect.TestNullArgs.Test2Args.")]
        public void Test2Argument_Fail()
        {
            var test = new TestNullArgs();
            test.Test2Args("pass", null);
        }

        [TestMethod]
        public void Test3Argument_Pass()
        {
            var test = new TestNullArgs();
            test.Test3Args("pass", "pass", "pass");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException),
            "Parameter name: Parameter(s) arg2 cannot be null for method Nvigorate.Test.Aspect.TestNullArgs.Test3Args.")]
        public void Test3Argument_SingleFail()
        {
            var test = new TestNullArgs();
            test.Test3Args("pass", null, "pass");
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException),
            "Parameter name: Parameter(s) arg1, arg3 cannot be null for method Nvigorate.Test.Aspect.TestNullArgs.Test3Args.")]
        public void Test3Argument_MultiFail()
        {
            var test = new TestNullArgs();
            test.Test3Args(null, "pass", null);
        }
    }

    [ArgumentCheckAspect]
    public class TestNullArgs
    {
        public void Test()
        {}

        public void Test1Arg(string arg1)
        {}

        public void Test2Args(string arg1, string arg2)
        { }

        public void Test3Args(string arg1, string arg2, string arg3)
        { }
    }

}
